﻿package mortal.game.resource
{
    import com.gengine.resource.*;
    import flash.utils.*;
    import mortal.game.resource.info.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.view.common.*;

    public class DailyRewardConfig extends Object
    {
        private var _dic:Dictionary;
        private static var _instance:DailyRewardConfig;

        public function DailyRewardConfig()
        {
            this._dic = new Dictionary();
            this.init();
            return;
        }// end function

        private function init() : void
        {
            var _loc_2:Object = null;
            var _loc_3:DailyRewardInfo = null;
            this._dic = new Dictionary();
            var _loc_1:* = ConfigManager.instance.getJSONByFileName("t_daily_reward.json");
            for each (_loc_2 in _loc_1)
            {
                
                _loc_3 = new DailyRewardInfo();
                ClassTypesUtil.copyValue(_loc_3, _loc_2);
                this._dic[_loc_3.code] = _loc_3;
            }
            return;
        }// end function

        public function getItemByCode(param1:int) : DailyRewardInfo
        {
            return this._dic[param1] as DailyRewardInfo;
        }// end function

        public function getRewardByCode(param1:int) : Array
        {
            var _loc_4:String = null;
            var _loc_5:Array = null;
            var _loc_6:ItemData = null;
            var _loc_7:int = 0;
            var _loc_2:* = this.getItemByCode(param1);
            var _loc_3:Array = [];
            if (_loc_2)
            {
                _loc_4 = _loc_2.item;
                _loc_5 = _loc_4.split("#");
                for each (_loc_7 in _loc_5)
                {
                    
                    _loc_6 = new ItemData(_loc_7);
                    _loc_3.push(_loc_6);
                }
            }
            return _loc_3;
        }// end function

        public static function get instance() : DailyRewardConfig
        {
            if (!_instance)
            {
                _instance = new DailyRewardConfig;
            }
            return _instance;
        }// end function

    }
}
